package vistas;

import controladores.CIngrediente;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JTextField;

public class VIngrediente extends javax.swing.JFrame {

    private Vector<JTextField> edit;
    private Vector<JButton> boton;
    private CIngrediente control;
    private AuxVista auxvista;

    public VIngrediente() {
        initComponents();
        boton = new Vector<JButton>();
        control= new CIngrediente(this);
        edit = new Vector<JTextField>();
        auxvista = new AuxVista();
        boton.add(btnSalir);
        boton.add(btnConsultar);
        boton.add(btnRegistrar);
        boton.add(btnCancelar);
        boton.add(btnEliminar);
        boton.add(btnActualizar);        

        edit.add(txtCodigo);
        edit.add(txtDescripcion);
        edit.add(txtNueCant);
        edit.add(txtCantidad);
        edit.add(txtPrecio);
        
        for (int i = 0; i < boton.size(); i++)
            boton.elementAt(i).addActionListener(control);
        reiniciar();
    }

   public boolean validarCamposVacios(){
      return auxvista.validarCamposVacios(edit);
    }

    public boolean validarNumeros(){
        return auxvista.validarNumeros(edit);
    }

    public void mostrar(){
        txtCodigo.setEditable(false);
        txtNueCant.setVisible(true);
        jLabel7.setVisible(true);
        txtNueCant.setText("0");
    }



     public void reiniciar(){
        auxvista.reiniciar(edit);
        txtCodigo.setEditable(true);
        txtCantidad.setEditable(true);
        txtNueCant.setVisible(false);
        jLabel7.setVisible(false);
        txtNueCant.setText("0");
    }

    public JTextField getTxtCantCom() {
        return txtNueCant;
    }

    public JTextField getTxtCantidad() {
        return txtCantidad;
    }

    public JTextField getTxtCodigo() {
        return txtCodigo;
    }

    public JTextField getTxtDescripcion() {
        return txtDescripcion;
    }

    public JTextField getTxtPrecio() {
        return txtPrecio;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
	btnRegistrar = new javax.swing.JButton("Registrar");
        btnConsultar = new javax.swing.JButton("Consultar");
        btnCancelar = new javax.swing.JButton("Cancelar");
        btnSalir = new javax.swing.JButton("Salir");
        btnActualizar = new javax.swing.JButton("Actualizar");
        btnEliminar = new javax.swing.JButton("Eliminar");
        jPanel1 = new javax.swing.JPanel();
        txtCantidad = new javax.swing.JTextField();
        txtNueCant = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtCodigo = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtPrecio = new javax.swing.JTextField();
        txtDescripcion = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Maestro de Ingredientes");
        getContentPane().setLayout(null);

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setLayout(null);

        btnRegistrar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnRegistrar.setText("Registrar");
        btnRegistrar.setPreferredSize(new java.awt.Dimension(80, 30));
        jPanel2.add(btnRegistrar);
        btnRegistrar.setBounds(30, 20, 120, 30);

        btnConsultar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        btnConsultar.setText("Consultar");
        jPanel2.add(btnConsultar);
        btnConsultar.setBounds(160, 20, 120, 30);

        btnCancelar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnCancelar.setText("Cancelar");
        btnCancelar.setPreferredSize(new java.awt.Dimension(80, 30));
        jPanel2.add(btnCancelar);
        btnCancelar.setBounds(30, 100, 120, 30);

        btnSalir.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnSalir.setText("Salir");
        jPanel2.add(btnSalir);
        btnSalir.setBounds(160, 100, 120, 30);

        btnActualizar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnActualizar.setText("Actualizar");
        btnActualizar.setPreferredSize(new java.awt.Dimension(80, 30));
        jPanel2.add(btnActualizar);
        btnActualizar.setBounds(160, 60, 120, 30);

        btnEliminar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnEliminar.setText("Eliminar");
        jPanel2.add(btnEliminar);
        btnEliminar.setBounds(30, 60, 120, 30);

        getContentPane().add(jPanel2);
        jPanel2.setBounds(40, 290, 290, 150);
        jPanel2.setBackground(new java.awt.Color(255,255,255));

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setLayout(null);

        txtCantidad.setFont(new java.awt.Font("Arial", 0, 13));
        jPanel1.add(txtCantidad);
        txtCantidad.setBounds(140, 130, 130, 30);

        txtNueCant.setFont(new java.awt.Font("Arial", 0, 13));
        txtNueCant.setText("0");
        jPanel1.add(txtNueCant);
        txtNueCant.setBounds(140, 170, 130, 30);

        jLabel6.setFont(new java.awt.Font("Ubuntu", 0, 13));
        jLabel6.setText("Codigo:");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(20, 10, 130, 30);

      
        jPanel1.add(txtCodigo);
        txtCodigo.setBounds(140, 10, 130, 30);

        jLabel5.setFont(new java.awt.Font("Ubuntu", 0, 13));
        jLabel5.setText("Cantidad:");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(20, 130, 130, 30);

        jLabel1.setFont(new java.awt.Font("Ubuntu", 0, 13));
        jLabel1.setText("Descripcion:");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(20, 50, 140, 32);

        jLabel3.setFont(new java.awt.Font("Ubuntu", 0, 13));
        jLabel3.setText("Precio:");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(20, 90, 224, 32);

        txtPrecio.setFont(new java.awt.Font("Arial", 0, 13));
        jPanel1.add(txtPrecio);
        txtPrecio.setBounds(140, 90, 130, 30);

        txtDescripcion.setFont(new java.awt.Font("Arial", 0, 13));
        jPanel1.add(txtDescripcion);
        txtDescripcion.setBounds(140, 50, 130, 32);

        jLabel7.setFont(new java.awt.Font("Ubuntu", 0, 13));
        jLabel7.setText("Nueva Cantidad:");
        jPanel1.add(jLabel7);
        jLabel7.setBounds(20, 170, 140, 30);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(40, 60, 290, 220);
        jPanel1.setBackground(new java.awt.Color(255,255,255));

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel4.setText("Ingredientes");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(130, 20, 172, 30);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 370, 486);
        getContentPane().setBackground(new java.awt.Color(14,151,255));
    }// </editor-fold>//GEN-END:initComponents


    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VIngrediente().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnActualizar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnRegistrar;
    private javax.swing.JButton btnSalir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField txtCantidad;
    private javax.swing.JTextField txtCodigo;
    private javax.swing.JTextField txtDescripcion;
    private javax.swing.JTextField txtNueCant;
    private javax.swing.JTextField txtPrecio;
    // End of variables declaration//GEN-END:variables

}
